package com.model;

/**
 * @author Erik
 * 2017-08-12
 * 员工信息类
 * @version 1.0
 * @since JDK1.8
 * @apiNote  public String info() 获取员工信息
 */
public class Employees {

    private String employName;
    private String employNo;
    private String employSex;
    private String employDute;
    private Company department;
    private int employAge;

    public Employees(){}

    /**
     * 四参构造函数
     * 将所有成员初始化
     * @param name  员工姓名
     * @param no    员工编号
     * @param sex   员工性别
     * @param duty  员工职务
     * @param age   员工年龄
     * @param depart    所属部门
     */
    public Employees(String name, String no, String sex, String duty, int age, Company depart){
        this.setEmployName(name);
        this.setEmployNo(no);
        this.setEmployAge(age);
        this.setEmploySex(sex);
        this.setEmployDute(duty);
        this.setDepartment(depart);
    }

    //getters
    String getEmployName()      {       return this.employName;     }
    String getEmployNo()        {       return this.employNo;       }
    String getEmploySex()       {       return this.employSex;      }
    String getEmployDute()      {       return this.employDute;     }
    Company getDepartment()     {       return this.department;     }
    int getEmployAge()          {       return this.employAge;      }

    //setters
    void setEmployName(String name)         {   this.employName=name;       }
    void setEmployNo(String no)             {   this.employNo=no;           }
    void setEmployDute(String dute)         {   this.employDute=dute;       }
    void setDepartment(Company department)  {   this.department=department; }
    void setEmployAge(int age)
    {
        if(age<18||age>60)
            this.employAge=0;
        else
            this.employAge=age;
    }
    void setEmploySex(String sex){
        if(sex.equals("男")||sex.equals("女"))
            this.employSex=sex;
        else
            this.employSex="NULL";
    }

    public String info(){
        String information="姓名:     "+this.getEmployName()
                +"\n工号:     "+this.getEmployNo()
                +"\n性别:     "+this.getEmploySex()
                +"\n年龄:     "+this.getEmployAge()
                +"\n职务:     "+this.getDepartment().getDepartName()+this.getEmployDute();
        return information;
    }
}
